$(function () {
    obj.init();

});

var obj = new function () {
    'use strict';
    return {
        dataGrid:null,
        schoolId:null,
        init:function () {
            this.schoolId    = xhTool.getQuery('schoolId');
            this.dataGrid = new xhDataGrid($('#list'), 'school_share/getCase/'+this.schoolId);
            this.dataGrid.parseToolbar().init().activeButton(['bt_list_del'], []);
            this.funObj().bindDataGridEvent();
            this.listener();
        },
        listener:function () {
            var $this = this;

            //删除
            $('#bt_list_del').on('click',function () {
                $this.funObj().askDelQuestion();
            });

            //搜索
            $('#bt_list_search').on('click',function () {
                $this.funObj().search();
            });


        },
        funObj:function () {
            var $this = this;
            return {
                bindDataGridEvent:function () {
                    // $this.dataGrid.onDblClickRow = function (rowIndex, rowData) {
                    //     window.top.xhTop.showModal({
                    //         title: '编辑分享',
                    //         content: '<iframe  src="'+baseUrl+'school_share/caseShareForm/'+$this.schoolId+'/'+rowData['iSCSId']+'"  style="width: 100%;;border-style: none;padding: 0px;height:300px"  scrolling="yes"   ></iframe>',
                    //         button:'提交'
                    //     });
                    // }
                },
                askDelQuestion:function () {
                    var ids = $this.dataGrid.getSelectValues('iSCSId');
                    xhExtra.askChangeStatus('school_share/delCase',{ids:ids},null,null,function (res) {
                        window.top.xhTop.showSuccess(res.msg);
                        $this.dataGrid.reload();
                    });
                },
                search:function () {
                    var key = xhExtra.getValue($('#list_search'));
                    $this.dataGrid.reload({key:key});
                }
            }
        }
    }
};